package com.AC.ACSougou;

import org.junit.Test;

public class test2 {

    public int getHouses (int t, int[] xa) {
        if(xa.length == 0)
            return 0;
        if(xa.length == 1)
            return 2;
        int res = 2;
        for(int i = 0; i<xa.length - 3; i += 2){
            if((xa[i+2] - xa[i+3] / 2.0) - (xa[i] + xa[i+1] / 2.0 ) > t)
                res += 2;
            else if((xa[i+2] - xa[i+3] / 2.0) - (xa[i] + xa[i+1] / 2.0 ) == t)
                res ++;
        }
        return res;
    }

    @Test
    public void test(){
        int[] arr = {-1,4,5,2,12,2,18,3,27,4};
        int t = 2;
        System.out.println(getHouses(t,arr));
    }
}
